<?php
/*
 * File authentication.php for project Rijlesplanner.nl
 * Created on Feb 25, 2008 at 10:14:30 PM by Ivar Pruijn
 */
 
$smarty = new Smarty_Rijlesplanner();
$auth = null; // the Authorization Manager
$user = null; // the User
$loggedIn = false; // whether the User is logged in already
if (!isset($_SESSION['user'])) {
	$user = new Visitor();
	 // default ACL for a visitor
	$user->setACL(
		array(
			"home"=>array(),
			"authentication"=>array(),
			"content"=>array(
				"options"=>array("overrijlesplanner","simulatorlessen","voorrijscholen","sitemap"),
				"actions"=>array()
			),
			"ookrijlessenmet"=>array(
				"options"=>array("ookrijlessenmet"),
				"actions"=>array("ookrijlessenmet")
			),
			"tellafriend" => array (
				"options" => array(
					"tellafriend"
				),
				"actions" => array(
					"sendtellafriend" 
				)
			),
			"reviews"=>array(
				"options" => array (
					"berichten"
				),
				"actions" => array (
				)
			),
			"persoonlijk"=>array(
				"options"=>array(),
				"actions"=>array()
			),
			"statistics"=>array(),
			"theorie"=>array(
				"options"=>array(),
				"actions"=>array()
			),
			"praktijk"=>array(
				"options"=>array(),
				"actions"=>array()
			),
			"blog" => array (
				"options" => array(),
				"actions" => array()
			)
		)
	);
	$_SESSION['user'] = $user;
	$auth = new AuthorizationManager($user);
	$_SESSION['auth'] = $auth;
} else {
	$user = $_SESSION['user'];
	if(isset($_SESSION['SessionId'])) {
		// user has logged in through the Web service because the SessionId variable is set
		$loggedIn = true;
	}
}
if (!isset($_SESSION['auth'])) {
	$auth = new AuthorizationManager($user);
} else {
	$auth = $_SESSION['auth'];
}

$smarty->assign('loggedIn',$loggedIn);
$smarty->assign('user',$user);
$auth->setUser($user);
$smarty->assign('auth',$auth);
?>
